import Koa from 'koa'
import Router from 'koa-router';
import SSE from './sse.js'

class Server {
    constructor() {
        const router = new Router()

        router
            .get('/', this.#ok)
            .get('/sse', ctx => new SSE(ctx))

        new Koa()
            .use(router.routes())
            .listen(8080, _ => console.log('Listening on http://localhost:8080/sse'));
    }

    #ok(ctx) {
        ctx.status = 200;
        ctx.body = 'OK!';
    }
}

new Server();
